package com.lwj.liwanjia.model;

import com.lwj.liwanjia.api.ApiService;
import com.lwj.liwanjia.bean.AddAdressBean;
import com.lwj.liwanjia.bean.AddressBean;
import com.lwj.liwanjia.utils.RetrofitHelper;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by Administrator on 2017/10/10.
 */

public class AddAdreessModel {
    public void addAddress(Map<String, Object> map, Subscriber<AddAdressBean> subscriber) {
        if(map.containsKey("consigneeId")) {//修改地址
            RetrofitHelper.getSingleRetrofit()
                    .create(ApiService.class)
                    .editAddress1(map)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(subscriber);
        }else{//新增地址
            RetrofitHelper.getSingleRetrofit()
                    .create(ApiService.class)
                    .addAddress(map)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(subscriber);
        }
    }
}
